product_list = [
    ('华为p30',3800),
    ('Mac Pro',16000),
    ('milk tea',15),
    ('Crabs',88),
    ('Watch',100050),
    ('Head First python',128),
    ('Book',100)
]

shopping_car = []
zhifubao = input("请您输入您的支付宝数字余额:")
if zhifubao.isdigit():
    zhifubao = int(zhifubao)
    while True:
        for item in product_list:  #
            print(product_list.index(item),item)   #打印元组，还要打印列表索引值
        choice = input('请输入商品编号：') #遍历出以后，输入商品名称
        if choice.isdigit():
            choice = int(choice)
            if choice >= 0 and choice <= 7:
                if zhifubao >= product_list[choice][1]:#钱够不够
                    zhifubao = zhifubao - product_list[choice][1]
                    shopping_car.append(product_list[choice])
                    print("您已经将商品%s添加到了购物车，你的支付宝余额是%s"%(product_list[choice][0],zhifubao))
                else:
                    print("您的支付宝余额不足，请选择其他商品")
            else:
                print("您选择的商品不再我们的商品列表里")
        elif choice == "q":
            print("------购物车清单-------")
            for item in shopping_car:
                print(item)
            print("您的支付宝余额是%s"% zhifubao)
            break
else:
    print("请输入数字形式的支付宝余额")

